package jpsearchcore;

import java.util.ArrayList;
import java.util.List;

public class Place { //may be extended to support save to XML (marshalling)
	private String label = "";
	private List<String> Name = new ArrayList<String>();
	private List<String> Description = new ArrayList<String>();
	
	public Place(){}
	
	public Place(String name, String description){
		if(name!=null)
			 Name.add(name);
		if(description!=null)
			Description.add(description);
	}
	
	public Place(String lbl, List<String> name, List<String> descr){
		label = lbl;
		Name = name;
		Description = descr;
	}
	
	public Place(String lbl, PlaceType placeT){		
		label = lbl;
		try{
			for(String s : placeT.getName()){
				Name.add(s.trim());
			}
		}
		catch(NullPointerException e){}	

		try{
			for(String s : placeT.getDescription()){
				Description.add(s.trim());
			}
		}
		catch(NullPointerException e){}
	}
	
	public List<String> getName(){
		return Name;
	}
	public String getAddressNameFull(){
		if(Name.isEmpty())
			return "";
		
		String address = "";
		for(String s : Name){
			address += s + " ";
		}
		return address.substring(0, address.length() - 1);
	}
	public List<String> getDescription(){
		return Description;
	}
	public String getAddressDescriptionFull(){
		if(Description.isEmpty())
			return "";
		
		String descr = "";
		for(String s : Description){
			descr += s + " ";
		}
		return descr.substring(0, descr.length() - 1);
	}
	
	public void setLabel(String label) {
		this.label = label;
	}

	public void setName(List<String> name) {
		Name = name;
	}

	public void setDescription(List<String> description) {
		Description = description;
	}

	public String toString(){
		
		String output = label + ":[\n\tName: ";
		for(String s : Name){
			output = output + s + " ";
		}
		output += "\n\tDescription: ";
		for(String s : Description){
			output = output + s + " ";
		}
		output += "]\n";
		return output;
	}
}
